In [1]:
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
from sklearn.pipeline import Pipeline
X = np.sort(np.random.rand(100))
y = np.cos(1.5 * np.pi * X) + np.random.randn(100) * 0.1
X = X[:, np.newaxis]
polynomial_features = PolynomialFeatures(degree=4);
linear_regression = LinearRegression();
#빠진 부분
model = Pipeline([("polynomial_features", polynomial_features), ("linear_regression", linear_regression)])
model.fit(X, y)
Out[1]:
In [5]:
Pipeline([("polynomial_feafures", polynomial_features)])
Out[5]: